package com.gbits.app.finance.convert;

import java.util.List;
import java.util.Map;

import com.gbits.app.finance.api.ItemFinanceConvert;
import com.gbits.app.finance.domain.Subject;

public class EmpSubjectConvert extends ItemFinanceConvert {
	private boolean debit;

	public boolean isDebit() {
		return debit;
	}

	public void setDebit(boolean debit) {
		this.debit = debit;
	}

	@Override
	public String getUsageInfo(Map<String, Object> map) {
		return this.getUsage(map);
	}

	@Override
	public String getSubjectDetail(Map<String, Object> map) {
		List<Subject> list = this.getSubjectService().getSubjectsByEmp(this.getCompanyCode(map));
		StringBuffer sb = new StringBuffer();
		for(Subject s : list) {
			sb.append(SUBJECT_SPLIT + s.getName());
		}
		sb.append("/999 - 其他");
		
		String str = list.get(list.size() - 1).getCode() + sb.toString();
		return str;
	}

	@Override
	public String getDebitAmount(Map<String, Object> map) {
		if (this.isDebit()) {
			return this.getAmount(map);
		}
		return "";
	}

	@Override
	public String getCreditAmount(Map<String, Object> map) {
		if (!this.isDebit()) {
			return this.getAmount(map);
		}
		return "";
	}

	@Override
	public boolean support(Map<String, Object> map) {
		return !this.isCompany(map);
	}
}
